home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 751-760 / 756 / popupmenu / source / popup.i < prev    next >
Text File  |  1995-03-18  |  7KB  |  245 lines

  1. ;   System constants
  2. AbsExecBase        equ     4
  3. TRUE            equ     1
  4. FALSE            equ     0
  5. WORD_MAX        equ     $7fff
  6. WORD_MIN        equ     $8000
  7. NULL            equ     0
  8.  
  9. ;   We need kickstart 2.04 (Not sure if V36 is OK)
  10. KICK204         equ     37
  11.  
  12. ;   Macros to call functions
  13. ;   Call a library function (Library base in A6)
  14. libcall         macro
  15.             jsr     _LVO\1(A6)
  16.             endm
  17.  
  18. ;   Call a standard C function
  19. call            macro
  20.             bsr     @\1
  21.             endm
  22.  
  23. MAXREMEMBER        equ     10    ; Remember last 10 selected menus
  24. DEFAULT_TIMEOUT     equ     50    ; == 1s
  25. INPUT_DEVICE_WAIT   equ     12    ; ~0,25 s
  26. ;   Don't know if this exists as a system constant
  27. HOTKEYBUFLENGTH     equ     40
  28.  
  29. ;   Qualifiers that may be used to cancel PopUpMenu
  30. QUALIFIERS        set     IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT!IEQUALIFIER_CONTROL
  31. QUALIFIERS        set     QUALIFIERS!IEQUALIFIER_LALT!IEQUALIFIER_RALT
  32. QUALIFIERS        set     QUALIFIERS!IEQUALIFIER_LCOMMAND!IEQUALIFIER_RCOMMAND
  33.  
  34.  
  35. ;   My versions of the flag bits
  36. ;   Name_B*   (* = no of bytes into flag field)
  37. ;   ex. bset WFLG_MENUSTATE_B2,wd_Flags+2(A?)
  38.  
  39. WFLG_MENUSTATE_B2   equ     7
  40. WFLG_RMBTRAP_B1     equ     0
  41. IDCMP_REFRESHWINDOW_B3 equ  2
  42. IDCMP_GADGETUP_B3   equ     6
  43. IDCMP_CLOSEWINDOW_B2 equ    1
  44. IDCMP_VANILLAKEY_B1 equ     5
  45. IDCMP_MENUVERIFY_B2 equ     5
  46. IDCMP_DELTAMOVE_B1  equ     4
  47.  
  48. MENUTOGGLED_B0        equ     6
  49. ISDRAWN_B0        equ     4
  50. HIGHITEM_B0        equ     5
  51. MENUTOGGLE_B1        equ     3
  52. MENUENABLED_B1        equ     0
  53. MIDRAWN_B0        equ     0
  54. ITEMENABLED_B1        equ     4
  55. CHECKIT_B1        equ     0
  56. CHECKED_B0        equ     0
  57. V_HIRES_B0        equ     7
  58.  
  59. ;    Our options
  60. CLICKMENUS        equ     %00000001
  61. SHOWSINGLEMENU        equ     %00000010
  62. ITEMSCENTERED        equ     %00000100
  63. POPUPWITHQUAL        equ     %00001000
  64. POPUPNOQUAL        equ     %00010000
  65. OPENOPTWINDOW        equ     %00100000
  66.  
  67. CLICKMENUS_B0        equ     0
  68. SHOWSINGLEMENU_B0   equ     1
  69. ITEMSCENTERED_B0    equ     2
  70. POPUPWITHQUAL_B0    equ     3
  71. POPUPNOQUAL_B0        equ     4
  72. OPENOPTWINDOW_B0    equ     5
  73.  
  74. ;   Handler flags
  75. MENUS_ON_B        equ     0
  76. M_DOWN_B        equ     1
  77. S_DOWN_B        equ     2
  78. CLICKON_B        equ     3
  79. NO_POPUP_B        equ     4
  80.  
  81.  
  82. ;   Data about the "Windows" used to display menus,items & subitems.
  83.  
  84.         STRUCTURE   WindowData,0
  85.         BOOL        wwd_BitMapOk       ; TRUE => window has bitmap
  86.         BOOL        wwd_ItemsEnabled       ; >0 if items are enabled
  87.         WORD        wwd_LeftEdge       ; On screen position
  88.         WORD        wwd_TopEdge
  89.         WORD        wwd_RightEdge
  90.         WORD        wwd_Bottom
  91.         WORD        wwd_Width           ; Size of window
  92.         WORD        wwd_Height
  93.         WORD        wwd_TopValue       ; Values to add to items position
  94.         WORD        wwd_LeftValue       ; to create screen coordinates
  95.         WORD        wwd_CommKeySize       ; Largest CommKey in this window
  96.         APTR        wwd_Items           ; List of items
  97.         APTR        wwd_Current        ; Currently selected item
  98.         STRUCT        wwd_Bm,bm_SIZEOF       ; Offscreen bitmap
  99.         LABEL        wwd_SIZEOF
  100.  
  101. ;   This structure is used to calculate the size of a window.
  102.         STRUCTURE   WindowSize,0
  103.         WORD        wws_Left
  104.         WORD        wws_Top
  105.         WORD        wws_Right
  106.         WORD        wws_Bottom
  107.         WORD        wws_CommKey
  108.         LABEL        wws_SIZEOF
  109.  
  110. ;   Used to remember selections between menu operations.
  111. ;   Notice that it is the menus (not the window) that is saved
  112.         STRUCTURE   LastMenus,0
  113.         APTR        llm_Menus        ; the menus
  114.         WORD        llm_Num        ; last selected menu
  115.         LABEL        llm_SIZEOF
  116.  
  117. ;   Used to keep data about allocated signals.
  118.         STRUCTURE   Signal,0
  119.         UWORD        ssi_Num
  120.         ULONG        ssi_Mask
  121.         LABEL        ssi_SIZEOF
  122.  
  123. ;   Data passed to our custom commodity handler.
  124.         STRUCTURE   SignalData,0
  125.         APTR        ssd_PopUpMenuTask    ; Where signals will go
  126.         UBYTE        ssd_Flags        ; internal to the handler
  127.         UBYTE        ssd_Options     ; Global options
  128.         UWORD        ssd_EndQualifier    ; Qualifiers pressed when signal sent
  129.  
  130.         LABEL        ssd_FirstSignal
  131.         STRUCT        ssd_MenuUpSig,ssi_SIZEOF     ; Menu button released
  132.         STRUCT        ssd_MenuDownSig,ssi_SIZEOF     ; Menu button pressed
  133.         STRUCT        ssd_SelectUpSig,ssi_SIZEOF     ; Select button released
  134.         STRUCT        ssd_SelectDownSig,ssi_SIZEOF ; Select button pressed
  135.         STRUCT        ssd_MouseMovedSig,ssi_SIZEOF ; Input device is still running
  136.  
  137.         LABEL        ssd_LastSignal
  138.         STRUCT        ssd_NotifySig,ssi_SIZEOF     ; Not used in our handler
  139.                              ; but is allocated in the same time
  140.         LABEL        ssd_SIZEOF
  141.  
  142. NO_OF_SIGNALS    EQU        (ssd_LastSignal-ssd_FirstSignal)/ssi_SIZEOF+1
  143.  
  144. ;   This is our expanded IntuiMessage that is sent to MENUVERIFY windows
  145. ;   ---> We are not increasing the size parameter in the ExecMessage! <---
  146.         STRUCTURE   MyMsg,im_SIZEOF
  147.         ULONG        mmn_Session
  148.         LABEL        mmn_SIZEOF
  149.  
  150. ;   All these global data are cleared at startup.
  151.         STRUCTURE   Globals,0
  152. ;   Library bases  (Always open)
  153.         APTR        _ExecBase        ; Placed first for speed
  154.         APTR        _DOSBase
  155.         APTR        _IntuitionBase
  156.         APTR        _GfxBase
  157.         APTR        _LayersBase
  158.         APTR        _CxBase
  159.  
  160. ;   Data used by the OptWindow routines [only valid when OptWindow open]
  161.         APTR        _GadToolsBase
  162.         APTR        _OptWindow
  163.         APTR        _GadgetList     ; all gadgets in window
  164.         APTR        _VisualInfo
  165.         STRUCT        _Gadgets,6*4    ; pointers to first six gadgets
  166.  
  167. ;   Following data is cleared before each menu popup
  168.         LABEL        _ClearStart
  169.  
  170. ;   MenuWindows (cleared)
  171.         STRUCT        _SubWindow,wwd_SIZEOF
  172.         STRUCT        _ItemWindow,wwd_SIZEOF
  173.         STRUCT        _MenuWindow,wwd_SIZEOF
  174.  
  175. ;   Selection data (cleared)
  176.         WORD        _CurrentMenuNr    ; Currently selected menu
  177.         WORD        _FirstSelected    ; First item selected MENUNUMBER
  178.         APTR        _LastSelected    ; Previus selection
  179.         APTR        _FirstDrag        ; First item to dragselect
  180.         WORD        _LastSelectedNum
  181.  
  182. ;   Some global data for selection (cleared)
  183.         APTR        _Menus        ; Menus we are using
  184.         WORD        _MenuTextHeight    ; Size of the menu strip
  185.         WORD        _CommKeyWidth    ; Default with of command key
  186.         BOOL        _ScreenType     ; TRUE = HIRES (for Amiga symbol)
  187.         STRUCT        _Rp,rp_SIZEOF    ; Copy of screens rastport
  188.         UBYTE        _DetailPen        ; Pens to use when drawing menus
  189.         UBYTE        _BlockPen        ; from window
  190.  
  191.         WORD        _MouseX        ; Mouse position
  192.         WORD        _MouseY
  193.  
  194.         STRUCT        _MenuSorted,32*4    ; sorted menus array
  195.         STRUCT        _Size,wws_SIZEOF    ; Used to determine size of windows
  196.  
  197.         LABEL        _ClearEnd
  198.  
  199. ;   not cleared
  200.         APTR        _ActiveWindow    ; Window and screen to use
  201.         APTR        _Screen
  202.  
  203. ;   startup data
  204.         APTR        _WBenchMsg        ; Startup message from WorkBench
  205.  
  206. ;   timer device stuff
  207.         APTR        _TimerReqBlock
  208.         APTR        _TimerPort
  209.         ULONG        _TimerSigMask
  210.         APTR        _ReplyPort
  211.  
  212. ;   broker data
  213.         APTR        _PopUpBroker    ; Our broker
  214.         APTR        _HotKeyFilterCxObj    ; translator object (needed to change hotkey)
  215.  
  216.         STRUCT        _HotKeyString,HOTKEYBUFLENGTH+1
  217.         ALIGNWORD
  218.  
  219. * ------------ Previus menus (array)
  220.         STRUCT        _LastMenus,(llm_SIZEOF*MAXREMEMBER)
  221.  
  222. * ------------ Data for the input handler
  223.         STRUCT        _CxHandlerData,ssd_SIZEOF
  224.  
  225. * ------------ that's all folks
  226.         LABEL        Globals_SIZEOF
  227.  
  228. ;  For some reason are all prefs includes missing in version 2.04.
  229.           IFND      IControlPrefs
  230.         STRUCTURE   IControlPrefs,0
  231.         STRUCT        ic_Reserved,4*4
  232.         UWORD        ic_TimeOut
  233.         WORD        ic_MetaDrag
  234.         ULONG        ic_Flags
  235.         UBYTE        ic_WBtoFront
  236.         UBYTE        ic_FrontToBack
  237.         UBYTE        ic_ReqTrue
  238.         UBYTE        ic_ReqFalse
  239.         LABEL        ic_SIZEOF
  240.           ENDC
  241.  
  242.  
  243.  
  244.  
  245.